'use strict';
const db = uniCloud.database(); // 连接到uniCloud的数据库
const newsCollection = db.collection('news')

// 云函数入口函数
exports.main = async (event, context) => {
	try {
		const {
			id
		} = event
		const res = await newsCollection.where({
			_id: id
		}).get()
		return {
			code: 0,
			data: res.data
		}
	} catch (err) {
		console.error(err)
		return {
			code: -1,
			msg: '获取新闻详情失败'
		}
	}
}